using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex
{
	/// <summary>
	/// Strongly-typed collection for the TblTrafficLog class.
	/// </summary>
	[Serializable]
	public partial class TblTrafficLogCollection : ActiveList<TblTrafficLog, TblTrafficLogCollection> 
	{	   
		public TblTrafficLogCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the tblTrafficLog table.
	/// </summary>
	[Serializable]
	public partial class TblTrafficLog : ActiveRecord<TblTrafficLog>
	{
		#region .ctors and Default Settings
		
		public TblTrafficLog()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public TblTrafficLog(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

		public TblTrafficLog(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public TblTrafficLog(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor
		public static Query CreateQuery() { return new Query(Schema); }

		
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("tblTrafficLog", TableType.Table, DataService.GetInstance("Adex"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarTrafficLogID = new TableSchema.TableColumn(schema);
				colvarTrafficLogID.ColumnName = "TrafficLogID";
				colvarTrafficLogID.DataType = DbType.Int32;
				colvarTrafficLogID.MaxLength = 0;
				colvarTrafficLogID.AutoIncrement = true;
				colvarTrafficLogID.IsNullable = false;
				colvarTrafficLogID.IsPrimaryKey = true;
				colvarTrafficLogID.IsForeignKey = false;
				colvarTrafficLogID.IsReadOnly = false;
				colvarTrafficLogID.DefaultSetting = @"";
				colvarTrafficLogID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTrafficLogID);
				
				TableSchema.TableColumn colvarMediaCode = new TableSchema.TableColumn(schema);
				colvarMediaCode.ColumnName = "MediaCode";
				colvarMediaCode.DataType = DbType.String;
				colvarMediaCode.MaxLength = 50;
				colvarMediaCode.AutoIncrement = false;
				colvarMediaCode.IsNullable = true;
				colvarMediaCode.IsPrimaryKey = false;
				colvarMediaCode.IsForeignKey = false;
				colvarMediaCode.IsReadOnly = false;
				colvarMediaCode.DefaultSetting = @"";
				colvarMediaCode.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMediaCode);
				
				TableSchema.TableColumn colvarMonday = new TableSchema.TableColumn(schema);
				colvarMonday.ColumnName = "Monday";
				colvarMonday.DataType = DbType.Int32;
				colvarMonday.MaxLength = 0;
				colvarMonday.AutoIncrement = false;
				colvarMonday.IsNullable = true;
				colvarMonday.IsPrimaryKey = false;
				colvarMonday.IsForeignKey = false;
				colvarMonday.IsReadOnly = false;
				colvarMonday.DefaultSetting = @"";
				colvarMonday.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMonday);
				
				TableSchema.TableColumn colvarTuesday = new TableSchema.TableColumn(schema);
				colvarTuesday.ColumnName = "Tuesday";
				colvarTuesday.DataType = DbType.Int32;
				colvarTuesday.MaxLength = 0;
				colvarTuesday.AutoIncrement = false;
				colvarTuesday.IsNullable = true;
				colvarTuesday.IsPrimaryKey = false;
				colvarTuesday.IsForeignKey = false;
				colvarTuesday.IsReadOnly = false;
				colvarTuesday.DefaultSetting = @"";
				colvarTuesday.ForeignKeyTableName = "";
				schema.Columns.Add(colvarTuesday);
				
				TableSchema.TableColumn colvarWednesday = new TableSchema.TableColumn(schema);
				colvarWednesday.ColumnName = "Wednesday";
				colvarWednesday.DataType = DbType.Int32;
				colvarWednesday.MaxLength = 0;
				colvarWednesday.AutoIncrement = false;
				colvarWednesday.IsNullable = true;
				colvarWednesday.IsPrimaryKey = false;
				colvarWednesday.IsForeignKey = false;
				colvarWednesday.IsReadOnly = false;
				colvarWednesday.DefaultSetting = @"";
				colvarWednesday.ForeignKeyTableName = "";
				schema.Columns.Add(colvarWednesday);
				
				TableSchema.TableColumn colvarThursday = new TableSchema.TableColumn(schema);
				colvarThursday.ColumnName = "Thursday";
				colvarThursday.DataType = DbType.Int32;
				colvarThursday.MaxLength = 0;
				colvarThursday.AutoIncrement = false;
				colvarThursday.IsNullable = true;
				colvarThursday.IsPrimaryKey = false;
				colvarThursday.IsForeignKey = false;
				colvarThursday.IsReadOnly = false;
				colvarThursday.DefaultSetting = @"";
				colvarThursday.ForeignKeyTableName = "";
				schema.Columns.Add(colvarThursday);
				
				TableSchema.TableColumn colvarFriday = new TableSchema.TableColumn(schema);
				colvarFriday.ColumnName = "Friday";
				colvarFriday.DataType = DbType.Int32;
				colvarFriday.MaxLength = 0;
				colvarFriday.AutoIncrement = false;
				colvarFriday.IsNullable = true;
				colvarFriday.IsPrimaryKey = false;
				colvarFriday.IsForeignKey = false;
				colvarFriday.IsReadOnly = false;
				colvarFriday.DefaultSetting = @"";
				colvarFriday.ForeignKeyTableName = "";
				schema.Columns.Add(colvarFriday);
				
				TableSchema.TableColumn colvarSaturday = new TableSchema.TableColumn(schema);
				colvarSaturday.ColumnName = "Saturday";
				colvarSaturday.DataType = DbType.Int32;
				colvarSaturday.MaxLength = 0;
				colvarSaturday.AutoIncrement = false;
				colvarSaturday.IsNullable = true;
				colvarSaturday.IsPrimaryKey = false;
				colvarSaturday.IsForeignKey = false;
				colvarSaturday.IsReadOnly = false;
				colvarSaturday.DefaultSetting = @"";
				colvarSaturday.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSaturday);
				
				TableSchema.TableColumn colvarSunday = new TableSchema.TableColumn(schema);
				colvarSunday.ColumnName = "Sunday";
				colvarSunday.DataType = DbType.Int32;
				colvarSunday.MaxLength = 0;
				colvarSunday.AutoIncrement = false;
				colvarSunday.IsNullable = true;
				colvarSunday.IsPrimaryKey = false;
				colvarSunday.IsForeignKey = false;
				colvarSunday.IsReadOnly = false;
				colvarSunday.DefaultSetting = @"";
				colvarSunday.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSunday);
				
				TableSchema.TableColumn colvarDateAdded = new TableSchema.TableColumn(schema);
				colvarDateAdded.ColumnName = "DateAdded";
				colvarDateAdded.DataType = DbType.DateTime;
				colvarDateAdded.MaxLength = 0;
				colvarDateAdded.AutoIncrement = false;
				colvarDateAdded.IsNullable = true;
				colvarDateAdded.IsPrimaryKey = false;
				colvarDateAdded.IsForeignKey = false;
				colvarDateAdded.IsReadOnly = false;
				colvarDateAdded.DefaultSetting = @"";
				colvarDateAdded.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDateAdded);
				
				TableSchema.TableColumn colvarDateModified = new TableSchema.TableColumn(schema);
				colvarDateModified.ColumnName = "DateModified";
				colvarDateModified.DataType = DbType.DateTime;
				colvarDateModified.MaxLength = 0;
				colvarDateModified.AutoIncrement = false;
				colvarDateModified.IsNullable = true;
				colvarDateModified.IsPrimaryKey = false;
				colvarDateModified.IsForeignKey = false;
				colvarDateModified.IsReadOnly = false;
				colvarDateModified.DefaultSetting = @"";
				colvarDateModified.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDateModified);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["Adex"].AddSchema("tblTrafficLog",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("TrafficLogID")]
		public int TrafficLogID 
		{
			get { return GetColumnValue<int>("TrafficLogID"); }

			set { SetColumnValue("TrafficLogID", value); }

		}

		  
		[XmlAttribute("MediaCode")]
		public string MediaCode 
		{
			get { return GetColumnValue<string>("MediaCode"); }

			set { SetColumnValue("MediaCode", value); }

		}

		  
		[XmlAttribute("Monday")]
		public int? Monday 
		{
			get { return GetColumnValue<int?>("Monday"); }

			set { SetColumnValue("Monday", value); }

		}

		  
		[XmlAttribute("Tuesday")]
		public int? Tuesday 
		{
			get { return GetColumnValue<int?>("Tuesday"); }

			set { SetColumnValue("Tuesday", value); }

		}

		  
		[XmlAttribute("Wednesday")]
		public int? Wednesday 
		{
			get { return GetColumnValue<int?>("Wednesday"); }

			set { SetColumnValue("Wednesday", value); }

		}

		  
		[XmlAttribute("Thursday")]
		public int? Thursday 
		{
			get { return GetColumnValue<int?>("Thursday"); }

			set { SetColumnValue("Thursday", value); }

		}

		  
		[XmlAttribute("Friday")]
		public int? Friday 
		{
			get { return GetColumnValue<int?>("Friday"); }

			set { SetColumnValue("Friday", value); }

		}

		  
		[XmlAttribute("Saturday")]
		public int? Saturday 
		{
			get { return GetColumnValue<int?>("Saturday"); }

			set { SetColumnValue("Saturday", value); }

		}

		  
		[XmlAttribute("Sunday")]
		public int? Sunday 
		{
			get { return GetColumnValue<int?>("Sunday"); }

			set { SetColumnValue("Sunday", value); }

		}

		  
		[XmlAttribute("DateAdded")]
		public DateTime? DateAdded 
		{
			get { return GetColumnValue<DateTime?>("DateAdded"); }

			set { SetColumnValue("DateAdded", value); }

		}

		  
		[XmlAttribute("DateModified")]
		public DateTime? DateModified 
		{
			get { return GetColumnValue<DateTime?>("DateModified"); }

			set { SetColumnValue("DateModified", value); }

		}

		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(string varMediaCode,int? varMonday,int? varTuesday,int? varWednesday,int? varThursday,int? varFriday,int? varSaturday,int? varSunday,DateTime? varDateAdded,DateTime? varDateModified)
		{
			TblTrafficLog item = new TblTrafficLog();
			
			item.MediaCode = varMediaCode;
			
			item.Monday = varMonday;
			
			item.Tuesday = varTuesday;
			
			item.Wednesday = varWednesday;
			
			item.Thursday = varThursday;
			
			item.Friday = varFriday;
			
			item.Saturday = varSaturday;
			
			item.Sunday = varSunday;
			
			item.DateAdded = varDateAdded;
			
			item.DateModified = varDateModified;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varTrafficLogID,string varMediaCode,int? varMonday,int? varTuesday,int? varWednesday,int? varThursday,int? varFriday,int? varSaturday,int? varSunday,DateTime? varDateAdded,DateTime? varDateModified)
		{
			TblTrafficLog item = new TblTrafficLog();
			
				item.TrafficLogID = varTrafficLogID;
				
				item.MediaCode = varMediaCode;
				
				item.Monday = varMonday;
				
				item.Tuesday = varTuesday;
				
				item.Wednesday = varWednesday;
				
				item.Thursday = varThursday;
				
				item.Friday = varFriday;
				
				item.Saturday = varSaturday;
				
				item.Sunday = varSunday;
				
				item.DateAdded = varDateAdded;
				
				item.DateModified = varDateModified;
				
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string TrafficLogID = @"TrafficLogID";
			 public static string MediaCode = @"MediaCode";
			 public static string Monday = @"Monday";
			 public static string Tuesday = @"Tuesday";
			 public static string Wednesday = @"Wednesday";
			 public static string Thursday = @"Thursday";
			 public static string Friday = @"Friday";
			 public static string Saturday = @"Saturday";
			 public static string Sunday = @"Sunday";
			 public static string DateAdded = @"DateAdded";
			 public static string DateModified = @"DateModified";
						
		}

		#endregion
	}

}

